#import "SelectSchoolViewController.h"

@interface SelectSchoolViewController ()

@end

@implementation SelectSchoolViewController
@synthesize school_list, type;
- (void)viewDidLoad {
    [super viewDidLoad];
    self.schoolTableView.delegate = self;
    self.schoolTableView.dataSource = self;
    //去除多余的分割线
    self.schoolTableView.tableFooterView = [[UIView alloc]init];
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)EditChanged:(id)sender {
    type = @"2";
}

- (IBAction)finishButton:(id)sender {
    NSString *schoolName = self.schoolNameInput.text;
    NSLog(@"school Name : %@",schoolName);
    
    [self.myDelegate setSchoolName:schoolName setType:type];
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)backButton:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell_tag"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell_tag"];
    }
    
    cell.textLabel.text = [NSString stringWithFormat:@"%@",[[school_list objectAtIndex:indexPath.row] objectForKey:@"name"]];
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return school_list.count;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    self.schoolNameInput.text = [[school_list objectAtIndex:indexPath.row]objectForKey:@"name"];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    cell.selected = NO;
    type = @"1";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
